package com.woniuxy.enjoylife.service.impl;

import com.woniuxy.enjoylife.entity.House;
import com.woniuxy.enjoylife.mapper.HouseMapper;
import com.woniuxy.enjoylife.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HouseServiceImpl implements HouseService {

    @Autowired
    private HouseMapper houseMapper;

    /**
     * 通过用户和房屋id设置默认认证房屋
     * @param id
     * @param uid
     * @return
     */
    @Override
    public boolean updateDefHouse(int id,int uid) {
        //取消原来的默认
        houseMapper.cancleDefHouse(uid);
        //从新添加默认
        return houseMapper.updateDefHouse(id)>0?true:false;
    }

    /**
     * 新增认证房屋
     * @param house
     * @return
     */
    @Override
    public boolean insertHouse(House house) {
        return houseMapper.insertHouse(house)>0?true:false;
    }

    /**
     * 删除认证房屋
     * @param id
     * @return
     */
    @Override
    public boolean delHouse(int id) {
        return houseMapper.delHouse(id)>0?true:false;
    }

    /**
     * 修改房屋
     * @param house
     * @return
     */
    @Override
    public boolean updateHouse(House house) {
        return houseMapper.updateHouse(house)>0?true:false;
    }

    /**
     * 查看房屋是否也被其他业主认证
     * @param house
     * @return
     */
    @Override
    public boolean isCertification(House house) {
        return houseMapper.isCertification(house)>0?true:false;
    }




}
